/**
 * token维护
 */
import { USER_TYPE } from "@/pd-libs/enum/pd-enum";
import PD from ".";
import { UniHelp } from "./uni-help";

const getTokenKey = () => {
	const currentAppConfig = PD.AppDeclare.getCurrentApp();
	return {
		[USER_TYPE.cp] : 'PD_CP_MINI_TOKEN',
		[USER_TYPE.driver] : 'PD_DRIVER_MINI_TOKEN',
		[USER_TYPE.passenger] : 'PD_PASSENGER_MINI_TOKEN',
		[USER_TYPE.cppc] : 'PD_CPPC_MINI_TOKEN',
	}[currentAppConfig!.userType];
};

export namespace Token {
	export const getToken = () : string => {
		return UniHelp.getStorage(getTokenKey());
	};
	export const setToken = (value : string) => {
		UniHelp.setStorage(getTokenKey(), value);
	};
	export const removeToken = () => {
		UniHelp.removeStorage(getTokenKey());
	};
}